Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use fetch_update instead of compare_exchange_weak #1119

Merged
merged 2 commits into from
Jan 26, 2024

Conversation

cuviper
Copy link
Member

@cuviper cuviper commented Jan 26, 2024

These are functionally equivalent, but fetch_update makes our code simpler.

Also, in the case of find_first/last, it's now optimized that we don't need a compare-exchange at all when the best position is already equal. That may happen in find_last when a result was already found in the current split, or in either method when the split resolution was exhausted.

Its manual `compare_exchange_weak` loop was exactly what `fetch_update`
does internally, so we might as well simplify our code.
Its manual `compare_exchange_weak` loop was exactly what `fetch_update`
does internally, and we can also improve on the case where the current
best index was already equal.
@cuviper cuviper added this pull request to the merge queue Jan 26, 2024
Merged via the queue into rayon-rs:master with commit ba8e1a1 Jan 26, 2024
4 checks passed
@cuviper cuviper deleted the fetch_update branch January 27, 2024 00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant